package com.magnificent.atlantis.client.ui.planner.panels.message.content;

import com.magnificent.atlantis.client.data.message.messages.ClientTextMessage;
import com.magnificent.atlantis.client.ui.planner.PlannerData;

import javax.swing.*;
import java.awt.*;

/**
 * User: Babanin
 * Date: 04.05.2009
 * Time: 14:48:03
 */
public class TextMessagePanel extends AbstractMessageContentPanel {
    private JTextPane messagePane;

    public TextMessagePanel(PlannerData plannerData) {
        super(plannerData);

        initializeControls();
        initializeView();
    }

    private void initializeView() {
        setLayout(new BorderLayout());

        messagePane.setBorder(BorderFactory.createLineBorder(Color.BLACK));

        add(messagePane, BorderLayout.CENTER);
    }

    private void initializeControls() {
        messagePane = new JTextPane();
    }

    public void messageSelected(Object message) {
        ClientTextMessage clientTextMessage = (ClientTextMessage) message;

        messagePane.setText(clientTextMessage.getMessage());

        repaint();
    }
}
